import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:xingsu/page/publish/publish_page.dart';
import 'package:xingsu/page/user/login_page.dart';
import 'package:xingsu/util/use_preferences.dart';

class GuideDialog extends Dialog {
  final String info =
      "1、需从该活动页面进入，并投稿列表游戏中的任意一款\n\n2、投稿视频满足相关性要求 (投稿前请务必了解相关性标准)\n\n3、投稿后三天内抖游客户端播放量>200即可完成任务，播放量可在我的-视频状态中查看\n注: 抖游客户端播放量请以活动页面展示的播放量数据为准\n\n完成任务即可拼手气瓜分10万现金红包，该红包为发行人计划给创作者的额外奖励，投稿视频自身产生的收益仍会正常结算，投稿前请先了解我们的相关性审核标准";

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        height: Get.height * 0.5,
        width: Get.width * 0.8,
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10),
            color: const Color(0xFF110739)),
        padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
        child: Column(
          children: [
            Expanded(
                child: Padding(
              padding: const EdgeInsets.symmetric(horizontal: 10),
              child: ListView(
                children: [
                  const Text(
                    "任务要求",
                    style: TextStyle(
                        fontSize: 16,
                        fontWeight: FontWeight.w700,
                        color: Colors.white),
                  ),
                  const SizedBox(
                    height: 10,
                  ),
                  Text(
                    info,
                    style: const TextStyle(color: Colors.white),
                  ),
                ],
              ),
            )),
            const SizedBox(
              height: 20,
            ),
            InkWell(
              onTap: () {
                Get.back();
                if (UserPreferences.getIsLogin()) {
                  Get.to(() => PublishPage());
                } else {
                  Get.to(() => LoginPage());
                }
              },
              child: Container(
                height: 40,
                alignment: Alignment.center,
                decoration: BoxDecoration(
                    gradient: const LinearGradient(
                        colors: [Color(0xFF8053F9), Color(0xFF5D77F3)],
                        begin: Alignment(0, 0),
                        end: Alignment(1, 1)),
                    borderRadius: BorderRadius.circular(20)),
                child: const Text(
                  "去投稿",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
            IconButton(
                onPressed: () {
                  Get.back();
                },
                icon: const Icon(
                  Icons.close,
                  color: Colors.white,
                ))
          ],
        ),
      ),
    );
  }
}

void showGuideDialog() {
  showDialog(
      useSafeArea: false,
      context: Get.context!,
      builder: (BuildContext context) {
        return GuideDialog();
      });
}
